package me.sealer.algorithm.tree;

/**
 * @author Sealer
 * Created on 17/02/26.
 * 孩子表示法建立二叉树结构
 */
public class BinaryTree<T extends Comparable> {
    /**
     * 数据域
     */
    private T data;
    /**
     * 左子树
     */
    private BinaryTree<T> leftChild;
    /**
     * 右子树
     */
    private BinaryTree<T> rightChild;


    public BinaryTree(T data) {
        this.data = data;
        this.leftChild = null;
        this.rightChild = null;
    }

    public T getData() {
        return data;
    }

    public BinaryTree<T> getLeftChild() {
        return leftChild;
    }

    public void setLeftChild(BinaryTree<T> leftChild) {
        this.leftChild = leftChild;
    }

    public BinaryTree<T> getRightChild() {
        return rightChild;
    }

    public void setRightChild(BinaryTree<T> rightChild) {
        this.rightChild = rightChild;
    }

    @Override
    public String toString() {
        return "BinaryTree{" +
                "data=" + data +
                '}';
    }
}
